glimpse(lodesresidents_blkgp)
## Rows: 155
## Columns: 15
## $ blkgroup <dbl> 510030101001, 510030101002, 510030101003, 5100301…
## $ medc_allblk <dbl> 24.17281, 34.11035, 29.70686, 22.44022, 17.74491,…
## $ medc_workinRegionblk <dbl> 5.269266, 11.406913, 9.025905, 5.388651, 3.464939…
## $ medc_within40blk <dbl> 7.443729, 12.420517, 10.480196, 7.207290, 5.55071…
## $ medc_25_employeesblk <dbl> 19.67874, 25.85719, 21.31691, 16.49003, 13.16050,…
## $ commutersInBlgr <int> 822, 666, 636, 1396, 991, 706, 771, 1066, 405, 68…
## $ commuterinRegionblk <int> 576, 447, 437, 1028, 767, 531, 602, 803, 312, 507…
## $ commuterw40blk <int> 643, 497, 489, 1124, 843, 571, 637, 873, 333, 551…
## $ commuter25blk <int> 750, 615, 583, 1299, 941, 659, 730, 1001, 380, 63…
## $ avgc_allblk <dbl> 26.56419, 32.68364, 29.94505, 22.19963, 16.95999,…
## $ avgc_workinRegionblk <dbl> 5.248561, 11.585876, 8.421038, 6.016676, 3.582384…
## $ avgc_within40blk <dbl> 7.401903, 12.448308, 10.004912, 7.713104, 5.54740…
## $ avgc_25_employeesblk <dbl> 18.84796, 27.83559, 22.77203, 17.17362, 13.14508,…
## $ county <int> 51003, 51003, 51003, 51003, 51003, 51003, 51003, …
## $ GEOID <chr> "510030101001", "510030101002", "510030101003", "…
metaresidents %>%
filter(su_blkgp == 1) %>%
select(varname, about) %>% as.list()
## $varname
## [1] "blkgroup" "county" "avgc_allblk"
## [4] "medc_allblk" "commutersInBlgr" "avgc_within40blk"
## [7] "medc_within40blk" "commuterw40blk" "avgc_25_employeesblk"
## [10] "medc_25_employeesblk" "commuter25blk" "avgc_workinRegionblk"
## [13] "medc_workinRegionblk" "commuterinRegionblk"
##
## $about
## [1] "12-digit census block group code"
## [2] "5-digit county code"
## [3] "Average \"as the crow flies\" commuting distance for all residents of the census block group"
## [4] "Median \"as the crow flies\" commuting distance for all residents of the census block group"
## [5] "The number of residents in each census block group who are represented in the data"
## [6] "Average \"as the crow flies\" commuting distance for residents of the census block group who work within 40 miles"
## [7] "Median \"as the crow flies\" commuting distance for residents of the census block group who work within 40 miles"
## [8] "The number of residents in the census block group who work within 40 miles of home"
## [9] "Average \"as the crow flies\" commuting distance for residents of the census block group who commute to a census tract that employs at least 25 residents from the region of interest"
## [10] "Median \"as the crow flies\" commuting distance for residents of the census block group who commute to a census tract that employs at least 25 residents of the region of interest"
## [11] "The number of residents in the census block group who commute to a census tract that employs at least 25 residents of the region of interest"
## [12] "Average \"as the crow flies\" commuting distance for residents of the census block group who work in the same region as where they live"
## [13] "Median \"as the crow flies\" commuting distance for residents of the census block group who work in the same region as where they live"
## [14] "The number of residents in the census block group who commute to work within the region of interest"
glimpse(lodesworkers_blkgp)
## Rows: 155
## Columns: 16
## $ blkgroup <dbl> 510030101001, 510030101002, 510030…
## $ medc_allworkersblkgr <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ medc_livewithin40blkgr <dbl> 7.493951, 11.784491, 8.676766, 5.9…
## $ medc_25_resblkgr <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ workersInblkgr <int> 140, 214, 166, 339, 420, 106, 225,…
## $ liveoutsideRegionblkgr <int> 25, 32, 35, 177, 207, 38, 82, 201,…
## $ liveinsideRegionblkgr <int> 115, 182, 131, 162, 213, 68, 143, …
## $ perc_workers_liveinRegionblkgr <dbl> 82.14286, 85.04673, 78.91566, 47.7…
## $ perc_workers_liveoutsideRegionblkgr <dbl> 17.85714, 14.95327, 21.08434, 52.2…
## $ workersw40blkgr <int> 94, 159, 122, 137, 191, 68, 141, 2…
## $ workers25blkgr <int> 137, 209, 163, 229, 319, 102, 203,…
## $ avgc_allworkersblkgr <dbl> 0.038552696, 1.276620580, 1.472421…
## $ avgc_livewithin40blkgr <dbl> 7.521537, 10.488870, 8.517770, 6.7…
## $ avgc_25_resblkgr <dbl> 0.06123478, 1.30716174, 1.60765274…
## $ county <int> 51003, 51003, 51003, 51003, 51003,…
## $ GEOID <chr> "510030101001", "510030101002", "5…
metaworkers %>%
filter(su_blkgp == 1) %>%
select(varname, about) %>% as.list()
## $varname
## [1] "blkgroup" "medc_allworkersblkgr"
## [3] "medc_livewithin40blkgr" "medc_25_resblkgr"
## [5] "workersInblkgr" "liveoutsideRegionblkgr"
## [7] "liveinsideRegionblkgr" "perc_workers_liveinRegionblkgr"
## [9] "perc_workers_liveoutsideRegionblkgr" "workersw40blkgr"
## [11] "workers25blkgr" "avgc_allworkersblkgr"
## [13] "avgc_livewithin40blkgr" "avgc_25_resblkgr"
## [15] "county"
##
## $about
## [1] "12-digit census block group code where the workers are employed (workplace census block group)"
## [2] "Median \"as the crow flies\" commuting distance for all workers employed in the census block group"
## [3] "Median \"as the crow flies\" commuting distance for workers employed in the census block group who live within 40 miles of work"
## [4] "Median \"as the crow flies\" commute for workers employed in the census block group who live in census tract where at least 25 region of interest workers live"
## [5] "The total number of workers employed in the census block group"
## [6] "The number of workers employed in the census block group that live outside the region of interest"
## [7] "The number of workers employed in the census block group who live outside the region of interest"
## [8] "The percent of workers employed in the census block group who live inside the region of interest"
## [9] "The percent of workers employed in the census block group who live outside the region of interest"
## [10] "The number of workers employed in the census block group who live within 40 miles of work"
## [11] "The number of workers employed in the census block group who live in a census tract where at least 25 region of interest workers live"
## [12] "Average \"as the crow flies\" commuting distance for all workers employed in the census block group"
## [13] "Average \"as the crow flies\" commuting distance for workers employed in the census block group who live within 40 miles of work"
## [14] "Average \"as the crow flies\" commute for workers employed in the census block group who live in census tract where at least 25 region of interest workers live"
## [15] "5-digit county code"
lodesresidents_blkgp %>% select(avgc_allblk, avgc_within40blk, avgc_25_employeesblk, avgc_workinRegionblk, medc_allblk, medc_within40blk, medc_25_employeesblk, medc_workinRegionblk) %>%
select(where(~is.numeric(.x))) %>%
as.data.frame() %>%
stargazer(., type = "text", title = "Summary Statistics", digits = 1,
summary.stat = c("mean", "sd", "min", "median", "max"))
##
## Summary Statistics
## ===================================================
## Statistic Mean St. Dev. Min Median Max
## ---------------------------------------------------
## avgc_allblk 25.4 8.7 13.3 24.3 78.4
## avgc_within40blk 9.1 5.1 3.1 7.4 22.6
## avgc_25_employeesblk 19.9 7.7 9.4 18.8 64.8
## avgc_workinRegionblk 7.7 5.9 1.4 5.3 24.3
## medc_allblk 25.1 9.1 12.8 23.9 78.9
## medc_within40blk 9.1 5.2 2.8 7.2 22.8
## medc_25_employeesblk 19.6 7.9 8.3 18.4 69.6
## medc_workinRegionblk 7.6 5.9 1.2 5.2 24.3
## ---------------------------------------------------
lodesworkers_blkgp %>% select(avgc_allworkersblkgr, avgc_livewithin40blkgr, avgc_25_resblkgr, medc_allworkersblkgr, medc_livewithin40blkgr, medc_25_resblkgr, perc_workers_liveoutsideRegionblkgr) %>%
select(where(~is.numeric(.x))) %>%
as.data.frame() %>%
stargazer(., type = "text", title = "Summary Statistics", digits = 1,
summary.stat = c("mean", "sd", "min", "median", "max"))
##
## Summary Statistics
## ==================================================================
## Statistic Mean St. Dev. Min Median Max
## ------------------------------------------------------------------
## avgc_allworkersblkgr 0.4 0.8 0.0 0.1 5.1
## avgc_livewithin40blkgr 10.4 4.7 2.5 8.8 27.9
## avgc_25_resblkgr 0.5 0.9 0.0 0.1 5.2
## medc_livewithin40blkgr 10.3 4.9 2.4 8.6 28.9
## perc_workers_liveoutsideRegionblkgr 36.1 11.3 14.5 35.8 77.7
## ------------------------------------------------------------------
longr <- lodesresidents_tract %>% select(c(tract, avgc_alltr, avgc_within40tr, avgc_25_employeestr, avgc_workinRegiontr, medc_alltr, medc_within40tr, medc_25_employeestr, medc_workinRegiontr)) %>%
pivot_longer(-tract, names_to = "measure", values_to = "value")
longr$measure <- factor(longr$measure,
levels = c("avgc_alltr", "medc_alltr", "avgc_within40tr", "medc_within40tr", "avgc_25_employeestr", "medc_25_employeestr", "avgc_workinRegiontr",
"medc_workinRegiontr"))
longr %>%
ggplot(aes(x = value, fill = measure)) +
scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
geom_histogram() +
facet_wrap(~measure, scales = "free", ncol = 2)
longr <- lodesresidents_blkgp %>% select(c(blkgroup, avgc_allblk, avgc_within40blk, avgc_25_employeesblk, avgc_workinRegionblk, medc_allblk, medc_within40blk, medc_25_employeesblk, medc_workinRegionblk)) %>%
pivot_longer(-blkgroup, names_to = "measure", values_to = "value")
longr$measure <- factor(longr$measure,
levels = c("avgc_allblk", "medc_allblk", "avgc_within40blk", "medc_within40blk", "avgc_25_employeesblk", "medc_25_employeesblk", "avgc_workinRegionblk",
"medc_workinRegionblk"))
longr %>%
ggplot(aes(x = value, fill = measure)) +
scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
geom_histogram() +
facet_wrap(~measure, scales = "free", ncol = 2)
longr <- lodesresidents_block %>% select(c(h_geocode, avgc_all, avgc_within40, avgc_25_employees, avgc_workinRegion, medc_all, medc_within40, medc_25_employees, medc_workinRegion)) %>%
pivot_longer(-h_geocode, names_to = "measure", values_to = "value")
longr$measure <- factor(longr$measure,
levels = c("avgc_all", "medc_all", "avgc_within40", "medc_within40", "avgc_25_employees", "medc_25_employees", "avgc_workinRegion",
"medc_workinRegion"))
longr %>%
ggplot(aes(x = value, fill = measure)) +
scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
geom_histogram() +
facet_wrap(~measure, scales = "free", ncol = 2)
longw <- lodesworkers_tract %>% select(c(tract, avgc_allworkerstr, avgc_livewithin40tr, avgc_25_restr, medc_allworkerstr, medc_livewithin40tr, medc_25_restr)) %>%
pivot_longer(-tract, names_to = "measure", values_to = "value")
longw$measure <- factor(longw$measure,
levels = c("avgc_allworkerstr", "medc_allworkerstr", "avgc_livewithin40tr", "medc_livewithin40tr", "avgc_25_restr", "medc_25_restr"))
longw %>%
ggplot(aes(x = value, fill = measure)) +
scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
geom_histogram() +
facet_wrap(~measure, scales = "free", ncol = 2)
longw <- lodesworkers_blkgp %>% select(c(blkgroup, avgc_allworkersblkgr, avgc_livewithin40blkgr, avgc_25_resblkgr, medc_allworkersblkgr, medc_livewithin40blkgr, medc_25_resblkgr)) %>%
pivot_longer(-blkgroup, names_to = "measure", values_to = "value")
longw$measure <- factor(longw$measure,
levels = c("avgc_allworkersblkgr", "medc_allworkersblkgr", "avgc_livewithin40blkgr", "medc_livewithin40blkgr", "avgc_25_resblkgr", "medc_25_resblkgr"))
longw %>%
ggplot(aes(x = value, fill = measure)) +
scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
geom_histogram() +
facet_wrap(~measure, scales = "free", ncol = 2)
longw <- lodesworkers_block %>% select(c(w_geocode, avgc_allworkers, avgc_livewithin40, avgc_25_res, medc_allworkers, medc_livewithin40, medc_25_res)) %>%
pivot_longer(-w_geocode, names_to = "measure", values_to = "value")
longw$measure <- factor(longw$measure,
levels = c("avgc_allworkers", "medc_allworkers", "avgc_livewithin40", "medc_livewithin40", "avgc_25_res", "medc_25_res"))
longw %>%
ggplot(aes(x = value, fill = measure)) +
scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
geom_histogram() +
facet_wrap(~measure, scales = "free", ncol = 2)
Average commute distance.
pal <- colorNumeric("plasma", reverse = T, domain = cvl_lodes_tract$avgc_alltr)
leaflet(cvl_lodes_tract) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes_tract,
fillColor = ~pal(avgc_alltr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes_tract$GEOID, "<br>",
"Average commute (mi): ", round(cvl_lodes_tract$avgc_alltr, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes_tract$avgc_alltr,
title = "Average commute (mi)", opacity = 0.7)
pal <- colorNumeric("plasma", reverse = T, domain = cvl_lodes_blkgp$avgc_allblk)
leaflet(cvl_lodes_blkgp) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes_blkgp,
fillColor = ~pal(avgc_allblk),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes_blkgp$GEOID, "<br>",
"Average commute (mi): ", round(cvl_lodes_blkgp$avgc_allblk, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes_blkgp$avgc_allblk,
title = "Average commute (mi)", opacity = 0.7)
Block level maps are slow to render and may be added later.
Average commmute distance.
pal <- colorNumeric("plasma", reverse = T, domain =
cvl_lodes_tract$avgc_allworkertr)
leaflet(cvl_lodes_tract) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes_tract,
fillColor = ~pal(avgc_allworkerstr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes_tract$GEOID, "<br>",
"Average commute (mi): ", round(cvl_lodes_tract$avgc_allworkerstr, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes_tract$avgc_allworkerstr,
title = "Average commute (mi)", opacity = 0.7)
pal <- colorNumeric("plasma", reverse = T, domain =
cvl_lodes_blkgp$avgc_allworkersblkgr)
leaflet(cvl_lodes_blkgp) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes_blkgp,
fillColor = ~pal(avgc_allworkersblkgr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes_blkgp$GEOID, "<br>",
"Average commute (mi): ", round(cvl_lodes_blkgp$avgc_allworkersblkgr, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes_blkgp$avgc_allworkersblkgr,
title = "Average commute (mi)", opacity = 0.7)
Block level maps are slow to render and may be added later.
Average commute among those who work with in 40 miles of home.
pal <- colorNumeric("plasma", reverse = T, domain = cvl_lodes_tract$avgc_within40tr)
leaflet(cvl_lodes_tract) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes_tract,
fillColor = ~pal(avgc_within40tr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes_tract$GEOID, "<br>",
"Average commute (mi): ", round(cvl_lodes_tract$avgc_within40tr, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes_tract$avgc_within40tr,
title = "Average commute (mi)", opacity = 0.7)
pal <- colorNumeric("plasma", reverse = T, domain = cvl_lodes_blkgp$avgc_within40blk)
leaflet(cvl_lodes_blkgp) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes_blkgp,
fillColor = ~pal(avgc_within40blk),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes_blkgp$GEOID, "<br>",
"Average commute (mi): ", round(cvl_lodes_blkgp$avgc_within40blk, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes_blkgp$avgc_within40blk,
title = "Average commute (mi)", opacity = 0.7)
Block level maps are slow to render and may be added later.
pal <- colorNumeric("plasma", reverse = T, domain = cvl_lodes_tract$avgc_livewithin40tr)
leaflet(cvl_lodes_tract) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes_tract,
fillColor = ~pal(avgc_livewithin40tr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes_tract$GEOID, "<br>",
"Average commute (mi): ", round(cvl_lodes_tract$avgc_livewithin40tr, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes_tract$avgc_livewithin40tr,
title = "Average commute (mi)", opacity = 0.7)
pal <- colorNumeric("plasma", reverse = T, domain = cvl_lodes_blkgp$avgc_livewithin40blkgr)
leaflet(cvl_lodes_blkgp) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes_blkgp,
fillColor = ~pal(avgc_livewithin40blkgr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes_blkgp$GEOID, "<br>",
"Average commute (mi): ", round(cvl_lodes_blkgp$avgc_livewithin40blkgr, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes_blkgp$avgc_livewithin40blkgr,
title = "Average commute (mi)", opacity = 0.7)
Block level maps are slow to render and may be added later.
Average commute distances for people who work and live in the Charlottesville region.
pal <- colorNumeric("plasma", reverse = T, domain = cvl_lodes_tract$avgc_workinRegiontr)
leaflet(cvl_lodes_tract) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes_tract,
fillColor = ~pal(avgc_workinRegiontr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes_tract$GEOID, "<br>",
"Average commute (mi): ", round(cvl_lodes_tract$avgc_workinRegiontr, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes_tract$avgc_workinRegiontr,
title = "Average commute (mi)", opacity = 0.7)
pal <- colorNumeric("plasma", reverse = T, domain = cvl_lodes_blkgp$avgc_workinRegionblk)
leaflet(cvl_lodes_blkgp) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes_blkgp,
fillColor = ~pal(avgc_workinRegionblk),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes_blkgp$GEOID, "<br>",
"Average commute (mi): ", round(cvl_lodes_blkgp$avgc_workinRegionblk, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes_blkgp$avgc_workinRegionblk,
title = "Average commute (mi)", opacity = 0.7)
Block level maps are slow to render and may be added later.
pal <- colorNumeric("plasma", reverse = T, domain = cvl_lodes_tract$perc_workers_liveoutsideRegiontr)
leaflet(cvl_lodes_tract) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes_tract,
fillColor = ~pal(perc_workers_liveoutsideRegiontr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes_tract$GEOID, "<br>",
"Percent of workers: ", round(cvl_lodes_tract$perc_workers_liveoutsideRegiontr, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes_tract$perc_workers_liveoutsideRegiontr,
title = "Percent of workers <br> who live outside Cville <br> region", opacity = 0.7)
pal <- colorNumeric("plasma", reverse = T, domain = cvl_lodes_blkgp$perc_workers_liveoutsideRegionblkgr)
leaflet(cvl_lodes_blkgp) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes_blkgp,
fillColor = ~pal(perc_workers_liveoutsideRegionblkgr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes_blkgp$GEOID, "<br>",
"Percent of workers: ", round(cvl_lodes_blkgp$perc_workers_liveoutsideRegionblkgr, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes_blkgp$perc_workers_liveoutsideRegionblkgr,
title = "Percent of workers <br> who live outside Cville <br> region", opacity = 0.7)
Block level maps are slow to render and may be added later.